// 简单TCP客户端
#include <stdio.h>
#include <stdlib.h>
#include <winSock.h>

#pragma comment(lib, "ws2_32.lib")

int main()
{
    WSAData data;
    WSAStartup(1, &data);

    char *servIP = "127.0.0.1";
    char *echoString = "hello world";

    SOCKET s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

    struct sockaddr_in servAddr;
    memset(&servAddr, 0, sizeof(servAddr));
    servAddr.sin_family = AF_INET;
    servAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
    servAddr.sin_port = htons(8080);

    connect(s, (struct sockaddr *)&servAddr, sizeof(servAddr));

    send(s, echoString, strlen(echoString), 0);
    /* recv(s,echoString, sizeof(echoString), 0);
	printf("%s\n",echoString);*/
    //有这两句客户端会收到服务器的回射

    closesocket(s);
    WSACleanup();
    return 0;
}
